package com.xmy.cultivate.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xmy.cultivate.annotaion.ApiMethod;
import com.xmy.cultivate.entity.*;
import com.xmy.cultivate.entity.response.ContinueInfo;
import com.xmy.cultivate.entity.response.YearAndQuarter;
import com.xmy.cultivate.entity.views.*;
import com.xmy.cultivate.service.*;
import com.xmy.cultivate.util.Code;
import com.xmy.cultivate.util.PageResult;
import com.xmy.cultivate.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * 续班表 前端控制器
 * </p>
 *
 * @author min
 * @since 2022-11-01
 */
@RestController
@RequestMapping("/api/renewClass")
public class RenewClassController extends BaseController {

    @Autowired
    IRenewClassService iRenewClassService;

    @Autowired
    IQuarterService iQuarterService;

    @Autowired
    IGradeService iGradeService;

    @Autowired
    IStudentGradeService iStudentGradeService;

    @Autowired
    IOrganizationService iOrganizationService;

    @Autowired
    IAuthAdminContentService iAuthAdminContentService;

    @Autowired
    IOrganizationDepartmentPrincipalService iOrganizationDepartmentPrincipalService;

    @Autowired
    IAuthTeacherClassifyService iAuthTeacherClassifyService;

    @Autowired
    ISchoolQuarterService iSchoolQuarterService;

    @GetMapping()
    public Result findAll(@RequestParam Map reMap, @RequestParam(value = "schoolIdList", defaultValue = "") String[] schoolIdList) {
        /*Integer pageNum = StringUtils.isEmpty((String)reMap.get("pageNum")) ? 1 : Integer.valueOf((String)reMap.get("pageNum"));
        Integer pageSize = StringUtils.isEmpty((String)reMap.get("pageSize")) ? 10: Integer.valueOf((String)reMap.get("pageSize"));

        Map<String,Object> searchMap = new HashMap<>();
        Page<Course> page = new Page<>(pageNum,pageSize);*/

        //Long SchoolId = Long.parseLong(reMap.get("schoolId").toString());
        String SubjectsId = (String) reMap.get("subjectsId");
        Integer YearPart = Integer.parseInt(reMap.get("yearPart").toString());
        Integer QuarterNum = Integer.parseInt(reMap.get("quarterNum").toString());
        String TeacherName = (String) reMap.get("teacherName");
        String StartDate = (String) reMap.get("startDate");
        String EndDate = (String) reMap.get("endDate");
        if (schoolIdList.length == 0) {
            //schoolIdList = baseSchoolIdStr.split(",");
        }


        Integer type = 1;
        if (reMap.get("type") != null) {
            type = Integer.parseInt((String) reMap.get("type"));
        }

        List<RenewClassRecord> renewClassRecordList = iRenewClassService.getRenewRecord(schoolIdList, SubjectsId, YearPart, QuarterNum, TeacherName, StartDate, EndDate, type, this.baseSchoolIdList);


        return new Result(Code.OK, new PageResult(renewClassRecordList, (long) renewClassRecordList.size(), 1L));
    }

    @GetMapping("/getRenewRecordForTrack")
    public Result getRenewRecordForTrack(@RequestParam Map reMap, @RequestParam(value = "schoolIdList", defaultValue = "") String[] schoolIdList) {
        String SubjectsId = (String) reMap.get("subjectsId");
        Integer YearPart = Integer.parseInt(reMap.get("yearPart").toString());
        Integer QuarterNum = Integer.parseInt(reMap.get("quarterNum").toString());
        String TeacherName = (String) reMap.get("teacherName");
        String StartDate = (String) reMap.get("startDate");
        String EndDate = (String) reMap.get("endDate");
        if (schoolIdList.length == 0) {
            //schoolIdList = baseSchoolIdStr.split(",");
        }

        String trackId = "1";
        if (reMap.get("trackId") != null) {
            trackId = (String) reMap.get("trackId");
        }

        List<RenewClassRecord> renewClassRecordList = iRenewClassService.getRenewRecordForTrack(schoolIdList, SubjectsId, YearPart, QuarterNum, TeacherName, StartDate, EndDate, trackId);


        return new Result(Code.OK, new PageResult(renewClassRecordList, (long) renewClassRecordList.size(), 1L));

    }

    /**
     * 交费率(缴费人数)
     *
     * @param reMap
     * @param schoolId
     * @param yearPart
     * @param quarterNum
     * @param yearClassId
     * @param classTypeId
     * @param periodsNum  期数：1为1期，2为2期
     * @param lessonType
     * @return
     * @throws ParseException
     */
    @ApiMethod(value = "home:repeat:contribution-rate", description = "缴费率")
    @GetMapping("/payFee")
    public Result payFee(@RequestParam Map<String, String> reMap,
                         @RequestParam(value = "schoolId", defaultValue = "", required = false) String schoolId,
                         @RequestParam(value = "teacherId", defaultValue = "", required = false) String teacherId,
                         @RequestParam(value = "yearPart", defaultValue = "", required = false) Integer yearPart,
                         @RequestParam(value = "quarterNum", defaultValue = "", required = false) Integer quarterNum,
                         @RequestParam(value = "yearClassId", defaultValue = "", required = false) String yearClassId,
                         @RequestParam(value = "classTypeId", defaultValue = "", required = false) String classTypeId,
                         @RequestParam(value = "periodsNum", defaultValue = "1", required = false) Integer periodsNum,
                         @RequestParam(value = "lessonType", defaultValue = "1", required = false) Integer lessonType,
                         @RequestParam(value = "subjectsId", required = false) String subjectsId,
                         @RequestParam(value = "type", defaultValue = "1", required = false) Integer type,
                         @RequestParam(value = "trackId", required = false) String trackId,
                         @RequestParam(value = "startDate", required = false) String startDate,
                         @RequestParam(value = "endDate", required = false) String endDate,
                         @RequestParam(value = "timeStart", required = false, defaultValue = "") String timeStart,
                         @RequestParam(value = "timeEnd", required = false, defaultValue = "") String timeEnd,
                         @RequestParam(value = "isCourseScheduling", defaultValue = "0", required = false) Integer isCourseScheduling,// 是否为到课未缴数据，0否1是
                         @RequestParam(value = "isDetails", defaultValue = "0", required = false) Integer isDetails,// 是否为详情，0否1是
                         @RequestParam(value = "paymentStaff", defaultValue = "1", required = false) Integer paymentStaff,// 1教学主管，2市场，3年级负责人，4火种，5个人（全职），6小校区主管
                         @RequestParam(value = "paymentStaffType", defaultValue = "1", required = false) Integer paymentStaffType,// 1个人赛道，2管理赛道，3承接赛道，4校区赛道
                         @RequestParam(value = "versionNum", defaultValue = "1", required = false) Integer versionNum,//版本号，1之前的版本（个人、校区老师、四大校区……），2优化后的版本（教学主管、市场、年级负责人……）
                         @RequestParam(value = "name", required = false) String name) throws ParseException {
        if (name == null || name.isEmpty()) {
            name = null;
        }

        List<RenewClassRecord> renewClassRecordList = new ArrayList<>();

        LocalDate currentDate = LocalDate.now();
        DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        String formattedDate = currentDate.format(dateFormatter);

        if (StringUtils.isBlank(startDate)) {
            startDate = formattedDate;
        }
        if (StringUtils.isBlank(endDate)) {
            endDate = formattedDate;
        }

        // 获取权限
        AuthAdminContent authAdminContent = iAuthAdminContentService.getPermissionForTeacherId(yearPart, quarterNum, this.adminId, this.baseSchoolIdStr);
        LeadDataRs leadDataRs = authAdminContent.getLeadDataRs();
        if (authAdminContent.getIsPerson() == 1) {
            if (isCourseScheduling == 0) {
                if (type != 1 && type != 2 && type != 7) {
                    return new Result(Code.OK, new PageResult(renewClassRecordList, (long) renewClassRecordList.size(), 1L));
                }
            }
        }

        Long adminId = 0L;

//        if (versionNum.equals(1)) {
//            if (StringUtils.isBlank(yearClassId)) {
//                yearClassId = authAdminContent.getYearClassIds();
//            } else {
//                String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
//                leadDataRs.setYearClassIds(leadYearClassId);
//
//                yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
//            }
//
//            if (StringUtils.isBlank(subjectsId)) {
//                subjectsId = authAdminContent.getSubjectsIds();
//            } else {
//                String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
//                leadDataRs.setSubjectsIds(leadSubjectsId);
//
//                subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
//            }
//
//            if (StringUtils.isBlank(schoolId)) {
//                schoolId = authAdminContent.getSchoolIds();
//            } else {
//                String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
//                leadDataRs.setSchoolIds(leadSchoolId);
//
//                schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
//            }
//        }
//        else if (versionNum.equals(2)) {

        Integer isManager = iOrganizationService.getIsManager(yearPart, quarterNum, this.adminId);

        // 判断是否为主管
        OrganizationDepartmentPrincipal organizationDepartmentPrincipal1 = iOrganizationDepartmentPrincipalService.getByDepartmentId("23,27,24,25", 1L, this.adminId, yearPart, quarterNum);

        // 判断是否为年级负责人
        OrganizationDepartmentPrincipal organizationDepartmentPrincipal2 = iOrganizationDepartmentPrincipalService.getByDepartmentId("23", 2L, this.adminId, yearPart, quarterNum);

        // 判断是否为火种老师
        AuthTeacherClassify authTeacherClassify1 = iAuthTeacherClassifyService.getTeacherClassifyByTeacherId(this.adminId, 3);

        // 判断是否为个人老师
        AuthTeacherClassify authTeacherClassify2 = iAuthTeacherClassifyService.getTeacherClassifyByTeacherId(this.adminId, 2);

        if (isManager > 0) {
            authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
            authAdminContent.setYearClassIds("0,1,2,3,4,5,6,7,8,9,10,11,12");
            authAdminContent.setSubjectsIds("1,2,3");
        } else if (organizationDepartmentPrincipal1 != null) {
            authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
            authAdminContent.setYearClassIds("0,1,2,3,4,5,6,7,8,9,10,11,12");
            authAdminContent.setSubjectsIds("1,2,3");
        } else if (organizationDepartmentPrincipal2 != null) {
            // 年级负责人（个人赛道能看所有，管理赛道只能看带班年级和负责年级）
            if (paymentStaffType.equals(1)) {
                authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
                authAdminContent.setYearClassIds("0,1,2,3,4,5,6,7,8,9,10,11,12");
                authAdminContent.setSubjectsIds("1,2,3");
            } else if (paymentStaffType.equals(2)) {
                // 带班年级
                String yearClassIds = iGradeService.getYearClassIdForTeacherId(yearPart, quarterNum, this.adminId);
                // 负责年级
                String yearClassIds2 = iOrganizationDepartmentPrincipalService.getYearClassIdsForTeacherId(yearPart, quarterNum, this.adminId, 2);
                if (StringUtils.isNotBlank(yearClassIds) && StringUtils.isNotBlank(yearClassIds2)) {
                    yearClassIds += "," + yearClassIds2;
                } else if (StringUtils.isNotBlank(yearClassIds2)) {
                    yearClassIds = yearClassIds2;
                }
                authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
                authAdminContent.setYearClassIds(yearClassIds);
                authAdminContent.setSubjectsIds("1,2,3");
            }

        } else if (authTeacherClassify1 != null) {
            //带班年级
            String yearClassIds = iGradeService.getYearClassIdForTeacherId(yearPart, quarterNum, this.adminId);
            authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
            authAdminContent.setYearClassIds(yearClassIds);
            authAdminContent.setSubjectsIds("1,2,3");
        } else if (authTeacherClassify2 != null) {

        }

        if (StringUtils.isBlank(yearClassId)) {
            yearClassId = authAdminContent.getYearClassIds();
        } else {
            String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
            leadDataRs.setYearClassIds(leadYearClassId);

            yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
        }

        if (StringUtils.isBlank(subjectsId)) {
            subjectsId = authAdminContent.getSubjectsIds();
        } else {
            String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
            leadDataRs.setSubjectsIds(leadSubjectsId);

            subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
        }

        if (StringUtils.isBlank(schoolId)) {
            schoolId = authAdminContent.getSchoolIds();
        } else {
            String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
            leadDataRs.setSchoolIds(leadSchoolId);

            schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
        }

//        }

        renewClassRecordList = iRenewClassService.getPayFee(schoolId, yearPart, quarterNum, subjectsId, type, startDate, endDate, trackId, lessonType, yearClassId, classTypeId, periodsNum, name, authAdminContent, leadDataRs, versionNum, paymentStaff, paymentStaffType, isDetails, teacherId, adminId, isCourseScheduling, timeStart, timeEnd);

        return new Result(Code.OK, new PageResult(renewClassRecordList, (long) renewClassRecordList.size(), 1L));
    }


    /**
     * 缴费率（数据统计）
     */
    @GetMapping("/payFeeIFeign")
    public List<RenewClassRecord> payFeeIFeign(@RequestParam(value = "schoolId", defaultValue = "", required = false) String schoolId,
                                               @RequestParam(value = "teacherId", defaultValue = "", required = false) String teacherId,
                                               @RequestParam(value = "yearPart", defaultValue = "", required = false) Integer yearPart,
                                               @RequestParam(value = "quarterNum", defaultValue = "", required = false) Integer quarterNum,
                                               @RequestParam(value = "yearClassId", defaultValue = "", required = false) String yearClassId,
                                               @RequestParam(value = "classTypeId", defaultValue = "", required = false) String classTypeId,
                                               @RequestParam(value = "periodsNum", defaultValue = "1", required = false) Integer periodsNum,
                                               @RequestParam(value = "lessonType", defaultValue = "1", required = false) Integer lessonType,
                                               @RequestParam(value = "subjectsId", required = false) String subjectsId,
                                               @RequestParam(value = "type", defaultValue = "1", required = false) Integer type,
                                               @RequestParam(value = "trackId", required = false) String trackId,
                                               @RequestParam(value = "startDate", required = false) String startDate,
                                               @RequestParam(value = "endDate", required = false) String endDate,
                                               @RequestParam(value = "timeStart", required = false, defaultValue = "") String timeStart,
                                               @RequestParam(value = "timeEnd", required = false, defaultValue = "") String timeEnd,
                                               @RequestParam(value = "isCourseScheduling", defaultValue = "0", required = false) Integer isCourseScheduling,// 是否为到课未缴数据，0否1是
                                               @RequestParam(value = "isDetails", defaultValue = "0", required = false) Integer isDetails,// 是否为详情，0否1是
                                               @RequestParam(value = "paymentStaff", defaultValue = "1", required = false) Integer paymentStaff,// 1教学主管，2市场，3年级负责人，4火种，5个人（全职），6小校区主管
                                               @RequestParam(value = "paymentStaffType", defaultValue = "1", required = false) Integer paymentStaffType,// 1个人赛道，2管理赛道，3承接赛道，4校区赛道
                                               @RequestParam(value = "versionNum", defaultValue = "1", required = false) Integer versionNum,//版本号，1之前的版本（个人、校区老师、四大校区……），2优化后的版本（教学主管、市场、年级负责人……）
                                               @RequestParam(value = "name", required = false) String name) throws ParseException {
        if (name == null || name.isEmpty()) {
            name = null;
        }

        List<RenewClassRecord> renewClassRecordList = new ArrayList<>();

        LocalDate currentDate = LocalDate.now();
        DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        String formattedDate = currentDate.format(dateFormatter);

        if (StringUtils.isBlank(startDate)) {
            startDate = formattedDate;
        }
        if (StringUtils.isBlank(endDate)) {
            endDate = formattedDate;
        }

        // 获取admin信息
        FenAdminData fenAdminData = iAuthAdminContentService.getAdminData(yearPart, quarterNum);
        // 获取权限
        AuthAdminContent authAdminContent = iAuthAdminContentService.getPermissionForTeacherId(yearPart, quarterNum, fenAdminData.getAdminId(), fenAdminData.getBaseSchoolIdStr());

        LeadDataRs leadDataRs = authAdminContent.getLeadDataRs();

        if (StringUtils.isBlank(yearClassId)) {
            yearClassId = authAdminContent.getYearClassIds();
        } else {
            String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
            leadDataRs.setYearClassIds(leadYearClassId);

            yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
        }

        if (StringUtils.isBlank(subjectsId)) {
            subjectsId = authAdminContent.getSubjectsIds();
        } else {
            String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
            leadDataRs.setSubjectsIds(leadSubjectsId);

            subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
        }

        if (StringUtils.isBlank(schoolId)) {
            schoolId = authAdminContent.getSchoolIds();
        } else {
            String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
            leadDataRs.setSchoolIds(leadSchoolId);

            schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
        }

        renewClassRecordList = iRenewClassService.getPayFee(schoolId, yearPart, quarterNum, subjectsId, type, startDate, endDate, trackId, lessonType, yearClassId, classTypeId, periodsNum, name, authAdminContent, leadDataRs, versionNum, paymentStaff, paymentStaffType, isDetails, teacherId, this.adminId, isCourseScheduling, timeStart, timeEnd);

        return renewClassRecordList;
    }

    /**
     * 市场部缴费率列表和中间的详情
     *
     * @param reMap
     * @param schoolId
     * @param yearPart
     * @param quarterNum
     * @param yearClassId
     * @param classTypeId
     * @param periodsNum  期数：1为1期，2为2期
     * @param lessonType
     * @return
     * @throws ParseException
     */
    @GetMapping("/payFeeMarket")
    public Result payFeeMarket(@RequestParam Map<String, String> reMap,
                               @RequestParam(value = "schoolId", defaultValue = "", required = false) String schoolId,
                               @RequestParam(value = "yearPart", defaultValue = "", required = false) Integer yearPart,
                               @RequestParam(value = "quarterNum", defaultValue = "", required = false) Integer quarterNum,
                               @RequestParam(value = "yearClassId", defaultValue = "", required = false) String yearClassId,
                               @RequestParam(value = "classTypeId", defaultValue = "", required = false) String classTypeId,
                               @RequestParam(value = "periodsNum", defaultValue = "1", required = false) Integer periodsNum,
                               @RequestParam(value = "marketTeacherId", defaultValue = "", required = false) String marketTeacherId,
                               @RequestParam(value = "teamId", defaultValue = "", required = false) String teamId,
                               @RequestParam(value = "trackType", defaultValue = "1", required = false) Integer trackType,
                               @RequestParam(value = "classify", defaultValue = "1", required = false) Integer classify,
                               @RequestParam(value = "lessonType", defaultValue = "1", required = false) Integer lessonType) throws ParseException {
        String subjectsId = reMap.get("subjectsId");
        String startDate = reMap.get("startDate");
        String endDate = reMap.get("endDate");
        String trackId = reMap.get("trackId");

        Integer type = 1;
        if (reMap.get("type") != null) {
            type = Integer.parseInt((String) reMap.get("type"));
        }

        // 获取权限
        AuthAdminContent authAdminContent = iAuthAdminContentService.getPermissionForTeacherId(yearPart, quarterNum, this.adminId, this.baseSchoolIdStr);
        LeadDataRs leadDataRs = authAdminContent.getLeadDataRs();
        if (authAdminContent.getIsPerson() == 1) {
            if (!type.equals(1) && !type.equals(2)) {
                return new Result(Code.OK, new PageResult<>(new ArrayList<>(), (long) 0, 1L));
            }
        }

        if (StringUtils.isBlank(yearClassId)) {
            yearClassId = authAdminContent.getYearClassIds();
        } else {
            String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
            leadDataRs.setYearClassIds(leadYearClassId);

            yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
        }

        if (StringUtils.isBlank(subjectsId)) {
            subjectsId = authAdminContent.getSubjectsIds();
        } else {
            String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
            leadDataRs.setSubjectsIds(leadSubjectsId);

            subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
        }

        if (StringUtils.isBlank(schoolId)) {
            schoolId = authAdminContent.getSchoolIds();
        } else {
            String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
            leadDataRs.setSchoolIds(leadSchoolId);

            schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
        }
        // 权限校区id
        String authAdminSchoolId = authAdminContent.getSchoolIdList().stream().map(Object::toString).collect(Collectors.joining(","));

        List<RenewClassRecord> renewClassRecordList = iRenewClassService.getPayFeeMarket(schoolId, yearPart, quarterNum, subjectsId, type, startDate, endDate, trackId, lessonType, yearClassId, classTypeId, periodsNum, marketTeacherId, trackType, classify, teamId, authAdminContent, leadDataRs);

        return new Result(Code.OK, new PageResult(renewClassRecordList, (long) renewClassRecordList.size(), 1L));
    }


    @ApiMethod(value = "home:repeat:contribution-rate", description = "缴费率")
    @GetMapping("/getPayFeeMarketForTeam")
    public Result getPayFeeMarketForTeam(@RequestParam Map<String, String> reMap,
                                         @RequestParam(value = "schoolId", defaultValue = "", required = false) String schoolId,
                                         @RequestParam(value = "yearPart", defaultValue = "", required = false) Integer yearPart,
                                         @RequestParam(value = "quarterNum", defaultValue = "", required = false) Integer quarterNum,
                                         @RequestParam(value = "yearClassId", defaultValue = "", required = false) String yearClassId,
                                         @RequestParam(value = "classTypeId", defaultValue = "", required = false) String classTypeId,
                                         @RequestParam(value = "periodsNum", defaultValue = "1", required = false) Integer periodsNum,
                                         @RequestParam(value = "marketTeacherId", defaultValue = "", required = false) String marketTeacherId,
                                         @RequestParam(value = "teamId", defaultValue = "", required = false) String teamId,
                                         @RequestParam(value = "trackType", defaultValue = "2", required = false) Integer trackType,
                                         @RequestParam(value = "classify", defaultValue = "1", required = false) Integer classify,
                                         @RequestParam(value = "lessonType", defaultValue = "1", required = false) Integer lessonType) throws ParseException {
        String subjectsId = reMap.get("subjectsId");
        String startDate = reMap.get("startDate");
        String endDate = reMap.get("endDate");
        String trackId = reMap.get("trackId");

        Integer type = 1;
        if (reMap.get("type") != null) {
            type = Integer.parseInt((String) reMap.get("type"));
        }

        // 获取权限
        AuthAdminContent authAdminContent = iAuthAdminContentService.getPermissionForTeacherId(yearPart, quarterNum, this.adminId, this.baseSchoolIdStr);
        LeadDataRs leadDataRs = authAdminContent.getLeadDataRs();
        if (authAdminContent.getIsPerson() == 1) {
            return new Result(Code.OK, new PageResult<>(new ArrayList<>(), (long) 0, 1L));
        }

        if (StringUtils.isBlank(yearClassId)) {
            yearClassId = authAdminContent.getYearClassIds();
        } else {
            String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
            leadDataRs.setYearClassIds(leadYearClassId);

            yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
        }

        if (StringUtils.isBlank(subjectsId)) {
            subjectsId = authAdminContent.getSubjectsIds();
        } else {
            String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
            leadDataRs.setSubjectsIds(leadSubjectsId);

            subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
        }

        if (StringUtils.isBlank(schoolId)) {
            schoolId = authAdminContent.getSchoolIds();
        } else {
            String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
            leadDataRs.setSchoolIds(leadSchoolId);

            schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
        }

        List<RenewClassRecord> renewClassRecordList = iRenewClassService.getPayFeeMarketForTeam(schoolId, yearPart, quarterNum, subjectsId, type, startDate, endDate, trackId, lessonType, yearClassId, classTypeId, periodsNum, marketTeacherId, trackType, classify, teamId, authAdminContent, leadDataRs);

        return new Result(Code.OK, new PageResult(renewClassRecordList, (long) renewClassRecordList.size(), 1L));
    }


    /**
     * 个人详情
     */
    @ApiMethod(value = "home:repeat:contribution-rate", description = "缴费率")
    @GetMapping("/getPayDetailList")
    public Result getPayDetailList(@RequestParam Map<String, String> reMap,
                                   @RequestParam(value = "yearPart", defaultValue = "", required = false) Integer yearPart,
                                   @RequestParam(value = "quarterNum", defaultValue = "", required = false) Integer quarterNum,
                                   @RequestParam(value = "yearClassId", defaultValue = "", required = false) String yearClassId,
                                   @RequestParam(value = "classTypeId", defaultValue = "", required = false) String classTypeId,
                                   @RequestParam(value = "periodsNum", defaultValue = "1", required = false) Integer periodsNum,
                                   @RequestParam(value = "type", defaultValue = "1", required = false) Integer type,
                                   @RequestParam(value = "timeStart", required = false, defaultValue = "") String timeStart,
                                   @RequestParam(value = "timeEnd", required = false, defaultValue = "") String timeEnd,
                                   @RequestParam(value = "isCourseScheduling", defaultValue = "0", required = false) Integer isCourseScheduling,// 是否为到课未缴数据，0否1是
                                   @RequestParam(value = "paymentStaffId", required = false) String paymentStaffId,// 负责人id（例如年级负责人id……）
                                   @RequestParam(value = "paymentStaff", defaultValue = "1", required = false) Integer paymentStaff,// 1教学主管，2市场，3年级负责人，4火种，5个人（全职），6小校区主管
                                   @RequestParam(value = "paymentStaffType", defaultValue = "1", required = false) Integer paymentStaffType,// 1个人赛道，2管理赛道，3承接赛道，4校区赛道
                                   @RequestParam(value = "versionNum", defaultValue = "1", required = false) Integer versionNum,//版本号，1之前的版本（个人、校区老师、四大校区……），2优化后的版本（教学主管、市场、年级负责人……）
                                   @RequestParam(value = "nextDateNum", defaultValue = "0", required = false) Integer isNextDateNum,// 已缴详情，0是正常，1是查询上个学期带班的数据是否在本学期已缴
                                   @RequestParam(value = "lessonType", defaultValue = "1", required = false) String lessonType) throws ParseException {
        String subjectsId = reMap.get("subjectsId");
        String startDate = reMap.get("startDate");
        String endDate = reMap.get("endDate");
        String trackId = reMap.get("trackId");
        String detailType = reMap.get("detailType");
        String schoolId = reMap.get("schoolId");
        String teacherId = reMap.get("teacherId");
        String gradeId = reMap.get("gradeId");

        Integer pageNum = StringUtils.isEmpty(reMap.get("pageNum")) ? 1 : Integer.valueOf(reMap.get("pageNum"));
        Integer pageSize = StringUtils.isEmpty(reMap.get("pageSize")) ? 10 : Integer.valueOf(reMap.get("pageSize"));
        IPage<StudentRatePay> iPage = new Page<>(pageNum, pageSize);

        LocalDate currentDate = LocalDate.now();
        DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        String formattedDate = currentDate.format(dateFormatter);

        if (StringUtils.isBlank(startDate)) {
            startDate = formattedDate;
        }
        if (StringUtils.isBlank(endDate)) {
            endDate = formattedDate;
        }

        // 获取权限
        AuthAdminContent authAdminContent = iAuthAdminContentService.getPermissionForTeacherId(yearPart, quarterNum, this.adminId, this.baseSchoolIdStr);
        LeadDataRs leadDataRs = authAdminContent.getLeadDataRs();
        if (authAdminContent.getIsPerson() == 1) {
            if (isCourseScheduling == 0) {
                if (!type.equals(1) && !type.equals(2)) {
                    return new Result(Code.OK, new PageResult<>(new ArrayList<>(), (long) 0, 1L));
                }
            }
        }
        if (StringUtils.isNotBlank(teacherId)) {
            if (!teacherId.equals(String.valueOf(leadDataRs.getTeacherId()))) {
                leadDataRs.setTeacherId(0L);
            }
        }

//        if (versionNum.equals(1)) {
//
//            if (StringUtils.isBlank(yearClassId)) {
//                yearClassId = authAdminContent.getYearClassIds();
//            } else {
//                String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
//                leadDataRs.setYearClassIds(leadYearClassId);
//
//                yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
//            }
//
//            if (StringUtils.isBlank(subjectsId)) {
//                subjectsId = authAdminContent.getSubjectsIds();
//            } else {
//                String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
//                leadDataRs.setSubjectsIds(leadSubjectsId);
//
//                subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
//            }
//
//            if (StringUtils.isBlank(schoolId)) {
//                schoolId = authAdminContent.getSchoolIds();
//            } else {
//                String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
//                leadDataRs.setSchoolIds(leadSchoolId);
//
//                schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
//            }
//        } else if (versionNum.equals(2)) {
        Integer isManager = iOrganizationService.getIsManager(yearPart, quarterNum, this.adminId);

        // 判断是否为主管
        OrganizationDepartmentPrincipal organizationDepartmentPrincipal1 = iOrganizationDepartmentPrincipalService.getByDepartmentId("23,27,24,25", 1L, this.adminId, yearPart, quarterNum);

        // 判断是否为年级负责人
        OrganizationDepartmentPrincipal organizationDepartmentPrincipal2 = iOrganizationDepartmentPrincipalService.getByDepartmentId("23", 2L, this.adminId, yearPart, quarterNum);


        // 判断是否为火种老师
        AuthTeacherClassify authTeacherClassify1 = iAuthTeacherClassifyService.getTeacherClassifyByTeacherId(this.adminId, 3);

        // 判断是否为个人老师
        AuthTeacherClassify authTeacherClassify2 = iAuthTeacherClassifyService.getTeacherClassifyByTeacherId(this.adminId, 2);

        if (isManager > 0) {
            authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
            authAdminContent.setYearClassIds("0,1,2,3,4,5,6,7,8,9,10,11,12");
            authAdminContent.setSubjectsIds("1,2,3");
        } else if (organizationDepartmentPrincipal1 != null) {
            authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
            authAdminContent.setYearClassIds("0,1,2,3,4,5,6,7,8,9,10,11,12");
            authAdminContent.setSubjectsIds("1,2,3");
        } else if (organizationDepartmentPrincipal2 != null) {
            // 年级负责人（个人赛道能看所有，管理赛道只能看带班年级和负责年级）
            if (paymentStaffType.equals(1)) {
                authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
                authAdminContent.setYearClassIds("0,1,2,3,4,5,6,7,8,9,10,11,12");
                authAdminContent.setSubjectsIds("1,2,3");
            } else if (paymentStaffType.equals(2)) {
                // 带班年级
                String yearClassIds = iGradeService.getYearClassIdForTeacherId(yearPart, quarterNum, this.adminId);
                // 负责年级
                String yearClassIds2 = iOrganizationDepartmentPrincipalService.getYearClassIdsForTeacherId(yearPart, quarterNum, this.adminId, 2);
                if (StringUtils.isNotBlank(yearClassIds) && StringUtils.isNotBlank(yearClassIds2)) {
                    yearClassIds += "," + yearClassIds2;
                } else if (StringUtils.isNotBlank(yearClassIds2)) {
                    yearClassIds = yearClassIds2;
                }
                authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
                authAdminContent.setYearClassIds(yearClassIds);
                authAdminContent.setSubjectsIds("1,2,3");
            }

        } else if (authTeacherClassify1 != null) {
            //带班年级
            String yearClassIds = iGradeService.getYearClassIdForTeacherId(yearPart, quarterNum, this.adminId);
            authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
            authAdminContent.setYearClassIds(yearClassIds);
            authAdminContent.setSubjectsIds("1,2,3");
        } else if (authTeacherClassify2 != null) {

        }


        if (StringUtils.isBlank(yearClassId)) {
            yearClassId = authAdminContent.getYearClassIds();
        } else {
            String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
            leadDataRs.setYearClassIds(leadYearClassId);

            yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
        }

        if (StringUtils.isBlank(subjectsId)) {
            subjectsId = authAdminContent.getSubjectsIds();
        } else {
            String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
            leadDataRs.setSubjectsIds(leadSubjectsId);

            subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
        }

        if (StringUtils.isBlank(schoolId)) {
            schoolId = authAdminContent.getSchoolIds();
        } else {
            String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
            leadDataRs.setSchoolIds(leadSchoolId);

            schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
        }

//        }

        iRenewClassService.getPayDetailList(iPage, yearPart, quarterNum, schoolId, teacherId, gradeId, subjectsId, type, startDate, endDate, trackId, detailType, lessonType, yearClassId, classTypeId, periodsNum, isNextDateNum, authAdminContent, leadDataRs, paymentStaff, paymentStaffType, versionNum, paymentStaffId, isCourseScheduling, timeStart, timeEnd);

        return new Result(Code.OK, new PageResult(iPage.getRecords(), iPage.getTotal(), iPage.getPages()));
    }

    /**
     * 市场部缴费率详情
     */
    @GetMapping("/getPayDetailListMarket")
    public Result getPayDetailListMarket(@RequestParam Map<String, String> reMap,
                                         @RequestParam(value = "yearPart", defaultValue = "", required = false) Integer yearPart,
                                         @RequestParam(value = "quarterNum", defaultValue = "", required = false) Integer quarterNum,
                                         @RequestParam(value = "yearClassId", defaultValue = "", required = false) String yearClassId,
                                         @RequestParam(value = "classTypeId", defaultValue = "", required = false) String classTypeId,
                                         @RequestParam(value = "periodsNum", defaultValue = "1", required = false) Integer periodsNum,
                                         @RequestParam(value = "marketTeacherId", defaultValue = "", required = false) String marketTeacherId,
                                         @RequestParam(value = "trackType", defaultValue = "1", required = false) Integer trackType,
                                         @RequestParam(value = "classify", defaultValue = "1", required = false) Integer classify,
                                         @RequestParam(value = "teamId", defaultValue = "", required = false) String teamId,
                                         @RequestParam(value = "nextDateNum", defaultValue = "0", required = false) Integer isNextDateNum,// 已缴详情，0是正常，1是查询上个学期带班的数据是否在本学期已缴
                                         @RequestParam(value = "lessonType", defaultValue = "1", required = false) String lessonType) throws ParseException {
        String subjectsId = reMap.get("subjectsId");
        String startDate = reMap.get("startDate");
        String endDate = reMap.get("endDate");
        String trackId = reMap.get("trackId");
        String detailType = reMap.get("detailType");
        String schoolId = reMap.get("schoolId");
        String teacherId = reMap.get("teacherId");
        String gradeId = reMap.get("gradeId");
        Integer pageNum = StringUtils.isEmpty(reMap.get("pageNum")) ? 1 : Integer.valueOf(reMap.get("pageNum"));
        Integer pageSize = StringUtils.isEmpty(reMap.get("pageSize")) ? 10 : Integer.valueOf(reMap.get("pageSize"));
        IPage<StudentRatePay> iPage = new Page<>(pageNum, pageSize);

        Integer type = 1;
        if (reMap.get("type") != null) {
            type = Integer.parseInt((String) reMap.get("type"));
        }

        // 获取权限
        AuthAdminContent authAdminContent = iAuthAdminContentService.getPermissionForTeacherId(yearPart, quarterNum, this.adminId, this.baseSchoolIdStr);
        LeadDataRs leadDataRs = authAdminContent.getLeadDataRs();
        if (authAdminContent.getIsPerson() == 1) {
//            return new Result(Code.OK, new PageResult<>(new ArrayList<>(), (long) 0, 1L));
        }
        if (StringUtils.isNotBlank(teacherId)) {
            if (!teacherId.equals(String.valueOf(leadDataRs.getTeacherId()))) {
                leadDataRs.setTeacherId(0L);
            }
        }

        if (StringUtils.isBlank(yearClassId)) {
            yearClassId = authAdminContent.getYearClassIds();
        } else {
            String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
            leadDataRs.setYearClassIds(leadYearClassId);

            yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
        }

        if (StringUtils.isBlank(subjectsId)) {
            subjectsId = authAdminContent.getSubjectsIds();
        } else {
            String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
            leadDataRs.setSubjectsIds(leadSubjectsId);

            subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
        }

        if (StringUtils.isBlank(schoolId)) {
            schoolId = authAdminContent.getSchoolIds();
        } else {
            String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
            leadDataRs.setSchoolIds(leadSchoolId);

            schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
        }

        iRenewClassService.getPayDetailListMarket(iPage, yearPart, quarterNum, schoolId, teacherId, gradeId, subjectsId, type, startDate, endDate, trackId, detailType, lessonType, yearClassId, classTypeId, periodsNum, marketTeacherId, trackType, classify, teamId, isNextDateNum, authAdminContent, leadDataRs);

        return new Result(Code.OK, new PageResult(iPage.getRecords(), iPage.getTotal(), iPage.getPages()));
    }


    /**
     * 缴费率图表数据
     *
     * @param yearPart
     * @param quarterNum
     * @param schoolId
     * @param yearClassId
     * @param classTypeId
     * @param type        1:总数据，2:校区数据，3:教师数据
     * @param lessonType
     * @return
     * @throws ParseException
     */
    @GetMapping("/payFeeChart")
    public Result payFeeChart(
            @RequestParam(value = "yearPart", required = false) Integer[] yearPart,
            @RequestParam(value = "quarterNum", required = false) Integer[] quarterNum,
            @RequestParam(value = "schoolId", required = false) Long[] schoolId,
            @RequestParam(value = "yearClassId", required = false) Integer[] yearClassId,
            @RequestParam(value = "classTypeId", required = false) Long[] classTypeId,
            @RequestParam(value = "subjectsId", required = false) Integer[] subjectsId,
            @RequestParam(value = "teacherId", required = false) Long[] teacherId,
            @RequestParam(value = "type", defaultValue = "", required = false) String type,
            @RequestParam(value = "periodsNum", defaultValue = "1", required = false) Integer periodsNum,
            @RequestParam(value = "lessonType", defaultValue = "1", required = false) Integer lessonType) {

        Quarter quarterNow = iQuarterService.getNowQuarter();
        //yearPart.length;

        //当前学期之前的
        List<YearAndQuarter> yearAndQuarterListBefore = new ArrayList<>();
        //当前学期及之后的
        List<YearAndQuarter> yearAndQuarterListAfter = new ArrayList<>();
        for (Integer itemYear : yearPart) {
            for (Integer itemNum : quarterNum) {
                Quarter quarter = iQuarterService.getOneForYearAndNum(itemYear, itemNum);
                if (quarter != null) {
                    YearAndQuarter yearAndQuarter = new YearAndQuarter();
                    yearAndQuarter.setYearPart(itemYear);
                    yearAndQuarter.setQuarterNum(itemNum);
                    if (quarter.getLevel() < quarterNow.getLevel()) {
                        yearAndQuarterListBefore.add(yearAndQuarter);
                    } else {
                        yearAndQuarterListAfter.add(yearAndQuarter);
                    }
                }
            }
        }
        List<RenewClassRecordChart> renewClassRecordList = iRenewClassService.payFeeChart(schoolId, yearAndQuarterListBefore, yearAndQuarterListAfter, quarterNum, subjectsId, teacherId, yearClassId, classTypeId, type, lessonType, periodsNum);

        return new Result(Code.OK, renewClassRecordList, "获取成功");
    }


    /**
     * 续报率
     *
     * @return
     */
    @ApiMethod(value = "home:repeat:continuation-rate", description = "续报率")
    @GetMapping("/continueFee")
    public Result continueFee(@RequestParam Map<String, String> reMap,
                              @RequestParam(value = "schoolId", required = false, defaultValue = "") String schoolId,
                              @RequestParam(value = "lessonType", required = false, defaultValue = "1") Integer lessonType,
                              @RequestParam(value = "type", required = false, defaultValue = "1") Integer type,
                              @RequestParam(value = "teacherId", defaultValue = "", required = false) String teacherId,
                              @RequestParam(value = "isDetails", defaultValue = "0", required = false) Integer isDetails,// 是否为详情，0否1是
                              @RequestParam(value = "paymentStaff", defaultValue = "1", required = false) Integer paymentStaff,// 1教学主管，2市场，3年级负责人，4火种，5个人（全职），6小校区主管
                              @RequestParam(value = "paymentStaffType", defaultValue = "1", required = false) Integer paymentStaffType,// 1个人赛道，2管理赛道，3承接赛道，4校区赛道
                              @RequestParam(value = "versionNum", defaultValue = "1", required = false) Integer versionNum,//版本号，1之前的版本（个人、校区老师、四大校区……），2优化后的版本（教学主管、市场、年级负责人……）
                              @RequestParam(value = "name", required = false) String name) throws ParseException {
        if (name == null || name.isEmpty()) {
            name = null;
        }
        String subjectsId = reMap.get("subjectsId");
        String startDate = reMap.get("startDate");
        String endDate = reMap.get("endDate");
        String trackId = reMap.get("trackId");
        Integer yearPart = Integer.parseInt(reMap.get("yearPart").toString());
        Integer quarterNum = Integer.parseInt(reMap.get("quarterNum").toString());
        String yearClassId = reMap.get("yearClassId") != null && !reMap.get("yearClassId").isEmpty() ? reMap.get("yearClassId") : null;
        String classTypeId = reMap.get("classTypeId") != null && !reMap.get("classTypeId").isEmpty() ? reMap.get("classTypeId") : null;
        Quarter quarter = iQuarterService.getOneForYearAndNum(yearPart, quarterNum);
        List<ContinueInfo> renewClassRecordList = new ArrayList<>();
        //2023年春季班前的不显示
        if (quarter == null || quarter.getId() <= 10) {
            return new Result(Code.OK, new PageResult(renewClassRecordList, 0L, 1L));
        }

        //获取权限
        AuthAdminContent authAdminContent = iAuthAdminContentService.getPermissionForTeacherId(yearPart, quarterNum, this.adminId, this.baseSchoolIdStr);
        LeadDataRs leadDataRs = authAdminContent.getLeadDataRs();

        if (authAdminContent.getIsPerson() == 1) {
            if (type != 1 && type != 2 && type != 7) {
                return new Result(Code.OK, new PageResult(renewClassRecordList, (long) renewClassRecordList.size(), 1L));
            }
        }

//        if (versionNum.equals(1)) {
//            if (StringUtils.isBlank(yearClassId)) {
//                yearClassId = authAdminContent.getYearClassIds();
//            } else {
//                String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
//                leadDataRs.setYearClassIds(leadYearClassId);
//
//                yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
//            }
//
//            if (StringUtils.isBlank(subjectsId)) {
//                subjectsId = authAdminContent.getSubjectsIds();
//            } else {
//                String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
//                leadDataRs.setSubjectsIds(leadSubjectsId);
//
//                subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
//            }
//
//            if (StringUtils.isBlank(schoolId)) {
//                schoolId = authAdminContent.getSchoolIds();
//            } else {
//                String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
//                leadDataRs.setSchoolIds(leadSchoolId);
//
//                schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
//            }
//
//            // 权限校区id
//            String authAdminSchoolId = authAdminContent.getSchoolIdList().stream().map(Object::toString).collect(Collectors.joining(","));
//
//        } else if (versionNum.equals(2)) {
        Integer isManager = iOrganizationService.getIsManager(yearPart, quarterNum, this.adminId);

        // 判断是否为主管
        OrganizationDepartmentPrincipal organizationDepartmentPrincipal1 = iOrganizationDepartmentPrincipalService.getByDepartmentId("23,27,24,25", 1L, this.adminId, yearPart, quarterNum);

        // 判断是否为年级负责人
        OrganizationDepartmentPrincipal organizationDepartmentPrincipal2 = iOrganizationDepartmentPrincipalService.getByDepartmentId("23", 2L, this.adminId, yearPart, quarterNum);


        // 判断是否为火种老师
        AuthTeacherClassify authTeacherClassify1 = iAuthTeacherClassifyService.getTeacherClassifyByTeacherId(this.adminId, 3);

        // 判断是否为个人老师
        AuthTeacherClassify authTeacherClassify2 = iAuthTeacherClassifyService.getTeacherClassifyByTeacherId(this.adminId, 2);

        if (isManager > 0) {
            authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
            authAdminContent.setYearClassIds("0,1,2,3,4,5,6,7,8,9,10,11,12");
            authAdminContent.setSubjectsIds("1,2,3");
        } else if (organizationDepartmentPrincipal1 != null) {
            authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
            authAdminContent.setYearClassIds("0,1,2,3,4,5,6,7,8,9,10,11,12");
            authAdminContent.setSubjectsIds("1,2,3");
        } else if (organizationDepartmentPrincipal2 != null) {
            // 年级负责人（个人赛道能看所有，管理赛道只能看带班年级和负责年级）
//            if (paymentStaffType.equals(1)) {
//                authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
//                authAdminContent.setYearClassIds("0,1,2,3,4,5,6,7,8,9,10,11,12");
//                authAdminContent.setSubjectsIds("1,2,3");
//            } else if (paymentStaffType.equals(2)) {
            // 带班年级
            String yearClassIds = iGradeService.getYearClassIdForTeacherId(yearPart, quarterNum, this.adminId);
            // 负责年级
            String yearClassIds2 = iOrganizationDepartmentPrincipalService.getYearClassIdsForTeacherId(yearPart, quarterNum, this.adminId, 2);
            if (StringUtils.isNotBlank(yearClassIds) && StringUtils.isNotBlank(yearClassIds2)) {
                yearClassIds += "," + yearClassIds2;
            } else if (StringUtils.isNotBlank(yearClassIds2)) {
                yearClassIds = yearClassIds2;
            }
            authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
            authAdminContent.setYearClassIds(yearClassIds);
            authAdminContent.setSubjectsIds("1,2,3");
//            }

        } else if (authTeacherClassify1 != null) {
            //带班年级
            String yearClassIds = iGradeService.getYearClassIdForTeacherId(yearPart, quarterNum, this.adminId);
            authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
            authAdminContent.setYearClassIds(yearClassIds);
            authAdminContent.setSubjectsIds("1,2,3");
        } else if (authTeacherClassify2 != null) {

        }


        if (StringUtils.isBlank(yearClassId)) {
            yearClassId = authAdminContent.getYearClassIds();
        } else {
            String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
            leadDataRs.setYearClassIds(leadYearClassId);

            yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
        }

        if (StringUtils.isBlank(subjectsId)) {
            subjectsId = authAdminContent.getSubjectsIds();
        } else {
            String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
            leadDataRs.setSubjectsIds(leadSubjectsId);

            subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
        }

        if (StringUtils.isBlank(schoolId)) {
            schoolId = authAdminContent.getSchoolIds();
        } else {
            String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
            leadDataRs.setSchoolIds(leadSchoolId);

            schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
        }

//        }

        renewClassRecordList = iRenewClassService.getContinueFee(yearPart, quarterNum, schoolId, subjectsId, type, startDate, endDate, trackId, lessonType, yearClassId, classTypeId, name, authAdminContent, leadDataRs, versionNum, paymentStaff, paymentStaffType, isDetails, teacherId);

        return new Result(Code.OK, new PageResult(renewClassRecordList, (long) renewClassRecordList.size(), 1L));
    }

    /**
     * 续报率详情
     *
     * @return
     */
    @ApiMethod(value = "home:repeat:continuation-rate", description = "续报率")
    @GetMapping("/getContinueFeeDetail")
    public Result getContinueFeeDetail(
            @RequestParam(value = "yearClassId", required = false) String yearClassId,
            @RequestParam(value = "classTypeId", required = false) String classTypeId,
            @RequestParam(value = "yearPart", required = true) Integer yearPart,
            @RequestParam(value = "quarterNum", required = true) Integer quarterNum,
            @RequestParam(value = "schoolId", required = false, defaultValue = "") String schoolId,
            @RequestParam(value = "subjectsId", required = false, defaultValue = "") String subjectsId,
            @RequestParam(value = "startDate", required = false, defaultValue = "") String startDate,
            @RequestParam(value = "endDate", required = false, defaultValue = "") String endDate,
            @RequestParam(value = "type", required = false, defaultValue = "") Integer type,
            @RequestParam(value = "teacherId", required = false, defaultValue = "") String teacherId,
            @RequestParam(value = "gradeId", required = false, defaultValue = "") String gradeId,
            @RequestParam(value = "paymentStaffId", required = false) String paymentStaffId,// 负责人id（例如年级负责人id……）
            @RequestParam(value = "paymentStaff", defaultValue = "1", required = false) Integer paymentStaff,// 1教学主管，2市场，3年级负责人，4火种，5个人（全职），6小校区主管
            @RequestParam(value = "paymentStaffType", defaultValue = "1", required = false) Integer paymentStaffType,// 1个人赛道，2管理赛道，3承接赛道，4校区赛道
            @RequestParam(value = "versionNum", defaultValue = "1", required = false) Integer versionNum,//版本号，1之前的版本（个人、校区老师、四大校区……），2优化后的版本（教学主管、市场、年级负责人……）
            @RequestParam(value = "detailType", required = false, defaultValue = "1") Integer detailType,
            @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(value = "lessonType", required = false, defaultValue = "1") Integer lessonType) throws ParseException {
        IPage<StudentGrade> iPage = new Page<>(pageNum, pageSize);

        // 获取权限
        AuthAdminContent authAdminContent = iAuthAdminContentService.getPermissionForTeacherId(yearPart, quarterNum, this.adminId, this.baseSchoolIdStr);
        LeadDataRs leadDataRs = authAdminContent.getLeadDataRs();
        if (authAdminContent.getIsPerson() == 1) {
            if (!type.equals(1) && !type.equals(2)) {
                return new Result(Code.OK, new PageResult<>(new ArrayList<>(), (long) 0, 1L));
            }
        }

        if (StringUtils.isNotBlank(teacherId)) {
            if (!teacherId.equals(String.valueOf(leadDataRs.getTeacherId()))) {
                leadDataRs.setTeacherId(0L);
            }
        }

//        if (versionNum.equals(1)) {
//
//            if (StringUtils.isBlank(yearClassId)) {
//                yearClassId = authAdminContent.getYearClassIds();
//            } else {
//                String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
//                leadDataRs.setYearClassIds(leadYearClassId);
//
//                yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
//            }
//
//            if (StringUtils.isBlank(subjectsId)) {
//                subjectsId = authAdminContent.getSubjectsIds();
//            } else {
//                String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
//                leadDataRs.setSubjectsIds(leadSubjectsId);
//
//                subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
//            }
//
//            if (StringUtils.isBlank(schoolId)) {
//                schoolId = authAdminContent.getSchoolIds();
//            } else {
//                String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
//                leadDataRs.setSchoolIds(leadSchoolId);
//
//                schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
//            }
//        } else if (versionNum.equals(2)) {
        Integer isManager = iOrganizationService.getIsManager(yearPart, quarterNum, this.adminId);

        // 判断是否为主管
        OrganizationDepartmentPrincipal organizationDepartmentPrincipal1 = iOrganizationDepartmentPrincipalService.getByDepartmentId("23,27,24,25", 1L, this.adminId, yearPart, quarterNum);

        // 判断是否为年级负责人
        OrganizationDepartmentPrincipal organizationDepartmentPrincipal2 = iOrganizationDepartmentPrincipalService.getByDepartmentId("23", 2L, this.adminId, yearPart, quarterNum);


        // 判断是否为火种老师
        AuthTeacherClassify authTeacherClassify1 = iAuthTeacherClassifyService.getTeacherClassifyByTeacherId(this.adminId, 3);

        // 判断是否为个人老师
        AuthTeacherClassify authTeacherClassify2 = iAuthTeacherClassifyService.getTeacherClassifyByTeacherId(this.adminId, 2);

        if (isManager > 0) {
            authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
            authAdminContent.setYearClassIds("0,1,2,3,4,5,6,7,8,9,10,11,12");
            authAdminContent.setSubjectsIds("1,2,3");
        } else if (organizationDepartmentPrincipal1 != null) {
            authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
            authAdminContent.setYearClassIds("0,1,2,3,4,5,6,7,8,9,10,11,12");
            authAdminContent.setSubjectsIds("1,2,3");
        } else if (organizationDepartmentPrincipal2 != null) {
            // 年级负责人（个人赛道能看所有，管理赛道只能看带班年级和负责年级）
//            if (paymentStaffType.equals(1)) {
//                authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
//                authAdminContent.setYearClassIds("0,1,2,3,4,5,6,7,8,9,10,11,12");
//                authAdminContent.setSubjectsIds("1,2,3");
//            } else if (paymentStaffType.equals(2)) {
            // 带班年级
            String yearClassIds = iGradeService.getYearClassIdForTeacherId(yearPart, quarterNum, this.adminId);
            // 负责年级
            String yearClassIds2 = iOrganizationDepartmentPrincipalService.getYearClassIdsForTeacherId(yearPart, quarterNum, this.adminId, 2);
            if (StringUtils.isNotBlank(yearClassIds) && StringUtils.isNotBlank(yearClassIds2)) {
                yearClassIds += "," + yearClassIds2;
            } else if (StringUtils.isNotBlank(yearClassIds2)) {
                yearClassIds = yearClassIds2;
            }
            authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
            authAdminContent.setYearClassIds(yearClassIds);
            authAdminContent.setSubjectsIds("1,2,3");
//            }

        } else if (authTeacherClassify1 != null) {
            //带班年级
            String yearClassIds = iGradeService.getYearClassIdForTeacherId(yearPart, quarterNum, this.adminId);
            authAdminContent.setSchoolIds(iSchoolQuarterService.getSchoolIdStr(yearPart, quarterNum));
            authAdminContent.setYearClassIds(yearClassIds);
            authAdminContent.setSubjectsIds("1,2,3");
        } else if (authTeacherClassify2 != null) {

        }


        if (StringUtils.isBlank(yearClassId)) {
            yearClassId = authAdminContent.getYearClassIds();
        } else {
            String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
            leadDataRs.setYearClassIds(leadYearClassId);

            yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
        }

        if (StringUtils.isBlank(subjectsId)) {
            subjectsId = authAdminContent.getSubjectsIds();
        } else {
            String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
            leadDataRs.setSubjectsIds(leadSubjectsId);

            subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
        }

        if (StringUtils.isBlank(schoolId)) {
            schoolId = authAdminContent.getSchoolIds();
        } else {
            String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
            leadDataRs.setSchoolIds(leadSchoolId);

            schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
        }

//        }

        iRenewClassService.getContinueFeeDetail(iPage, yearPart, quarterNum, schoolId, subjectsId, type, startDate, endDate, lessonType, teacherId, gradeId, yearClassId, classTypeId, authAdminContent, leadDataRs, paymentStaff, paymentStaffType, versionNum, paymentStaffId, detailType);

        return new Result(Code.OK, new PageResult(iPage.getRecords(), iPage.getTotal(), iPage.getPages()));
    }

    /**
     * 市场部续报率,
     */
    @GetMapping("/continueFeeMarket")
    public Result continueFeeMarket(@RequestParam Map<String, String> reMap,
                                    @RequestParam(value = "schoolId", required = false, defaultValue = "") String schoolId,
                                    @RequestParam(value = "classify", required = false, defaultValue = "4") Integer classify,
                                    @RequestParam(value = "trackType", required = false, defaultValue = "1") Integer trackType,
                                    @RequestParam(value = "lessonType", required = false, defaultValue = "1") Integer lessonType) throws ParseException {
        String subjectsId = reMap.get("subjectsId");
        String startDate = reMap.get("startDate");
        String endDate = reMap.get("endDate");
        String trackId = reMap.get("trackId");
        Integer yearPart = Integer.parseInt(reMap.get("yearPart").toString());
        Integer quarterNum = Integer.parseInt(reMap.get("quarterNum").toString());
        String yearClassId = reMap.get("yearClassId") != null && !reMap.get("yearClassId").isEmpty() ? reMap.get("yearClassId") : null;
        String classTypeId = reMap.get("classTypeId") != null && !reMap.get("classTypeId").isEmpty() ? reMap.get("classTypeId") : null;

        List<ContinueInfo> renewClassRecordList = iRenewClassService.getContinueFeeMarket(yearPart, quarterNum, schoolId, subjectsId, startDate, endDate, lessonType, yearClassId, classTypeId, classify, trackType, trackId);

        return new Result(Code.OK, new PageResult(renewClassRecordList, (long) renewClassRecordList.size(), 1L));
    }

    /**
     * 市场部续报率详情
     */
    @GetMapping("/getContinueFeeDetailMarket")
    public Result getContinueFeeDetailMarket(
            @RequestParam(value = "yearClassId", required = false) String yearClassId,
            @RequestParam(value = "classTypeId", required = false) String classTypeId,
            @RequestParam(value = "yearPart", required = true) Integer yearPart,
            @RequestParam(value = "quarterNum", required = true) Integer quarterNum,
            @RequestParam(value = "schoolId", required = false, defaultValue = "") String schoolId,
            @RequestParam(value = "subjectsId", required = false, defaultValue = "") String subjectsId,
            @RequestParam(value = "startDate", required = false, defaultValue = "") String startDate,
            @RequestParam(value = "endDate", required = false, defaultValue = "") String endDate,
            @RequestParam(value = "teamId", required = false, defaultValue = "") String teamId,
            @RequestParam(value = "gradeId", required = false, defaultValue = "") String gradeId,
            @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(value = "trackId", required = false, defaultValue = "") String trackId,
            @RequestParam(value = "classify", required = false, defaultValue = "4") Integer classify,
            @RequestParam(value = "trackType", required = false, defaultValue = "1") Integer trackType,
            @RequestParam(value = "lessonType", required = false, defaultValue = "1") Integer lessonType) throws ParseException {
        IPage<StudentGrade> iPage = new Page<>(pageNum, pageSize);

        iRenewClassService.getContinueFeeDetailMarket(iPage, yearPart, quarterNum, schoolId, subjectsId, startDate, endDate, lessonType, teamId, gradeId, yearClassId, classTypeId, classify, trackType, trackId);

        return new Result(Code.OK, new PageResult(iPage.getRecords(), iPage.getTotal(), iPage.getPages()));
    }

    /**
     * 市场部续报率详情中的详情
     */
    @GetMapping("/getRenewRecordDetailMarketBySourseId")
    public Result getRenewRecordDetailMarketBySourseId(
            @RequestParam(value = "yearClassId", required = false) String yearClassId,
            @RequestParam(value = "classTypeId", required = false) String classTypeId,
            @RequestParam(value = "yearPart", required = true) Integer yearPart,
            @RequestParam(value = "quarterNum", required = true) Integer quarterNum,
            @RequestParam(value = "schoolId", required = false, defaultValue = "") String schoolId,
            @RequestParam(value = "subjectsId", required = false, defaultValue = "") String subjectsId,
            @RequestParam(value = "startDate", required = false, defaultValue = "") String startDate,
            @RequestParam(value = "endDate", required = false, defaultValue = "") String endDate,
            @RequestParam(value = "teamId", required = false, defaultValue = "") String teamId,
            @RequestParam(value = "sourseId", required = false, defaultValue = "") String sourseId,
            @RequestParam(value = "detailType", required = false, defaultValue = "") String detailType,
            @RequestParam(value = "classify", required = false, defaultValue = "1") Integer classify,
            @RequestParam(value = "trackType", required = false, defaultValue = "1") Integer trackType,
            @RequestParam(value = "gradeId", required = false, defaultValue = "") String gradeId,
            @RequestParam(value = "trackId", required = false, defaultValue = "") String trackId,
            @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(value = "lessonType", required = false, defaultValue = "1") Integer lessonType) throws ParseException {
        IPage<StudentGrade> iPage = new Page<>(pageNum, pageSize);

        // 获取权限
        AuthAdminContent authAdminContent = iAuthAdminContentService.getPermissionForTeacherId(yearPart, quarterNum, this.adminId, this.baseSchoolIdStr);
        LeadDataRs leadDataRs = authAdminContent.getLeadDataRs();
        if (authAdminContent.getIsPerson() == 1) {
//            return new Result(Code.OK, new PageResult<>(new ArrayList<>(), (long) 0, 1L));
        }

        if (StringUtils.isBlank(yearClassId)) {
            yearClassId = authAdminContent.getYearClassIds();
        } else {
            String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
            leadDataRs.setYearClassIds(leadYearClassId);

            yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
        }

        if (StringUtils.isBlank(subjectsId)) {
            subjectsId = authAdminContent.getSubjectsIds();
        } else {
            String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
            leadDataRs.setSubjectsIds(leadSubjectsId);

            subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
        }

        if (StringUtils.isBlank(schoolId)) {
            schoolId = authAdminContent.getSchoolIds();
        } else {
            String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
            leadDataRs.setSchoolIds(leadSchoolId);

            schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
        }
        // 权限校区id
        String authAdminSchoolId = authAdminContent.getSchoolIdList().stream().map(Object::toString).collect(Collectors.joining(","));

        if (StringUtils.isNotBlank(sourseId)) {
            if (!sourseId.equals(String.valueOf(leadDataRs.getTeacherId()))) {
                leadDataRs.setTeacherId(0L);
            }
        }

        iRenewClassService.getRenewRecordDetailMarketBySourseId(iPage, yearPart, quarterNum, schoolId, subjectsId, startDate, endDate, lessonType, teamId, gradeId, yearClassId, classTypeId, sourseId, detailType, classify, trackType, trackId, authAdminContent, leadDataRs);

        return new Result(Code.OK, new PageResult(iPage.getRecords(), iPage.getTotal(), iPage.getPages()));
    }


    @GetMapping("gradeList")
    @ApiOperation("班级查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "teacherId", value = "老师id", required = false, dataType = "String"),
            @ApiImplicitParam(name = "schoolId", value = "学校id", required = false, dataType = "String"),
    })
    public Result gradeList(@RequestParam("teacherId") String teacherId,
                            @RequestParam("schoolId") String schoolId,
                            @RequestParam("subjectsId") String subjectsId) {
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(StringUtils.isNotBlank(teacherId), "teacher_id", teacherId);
        queryWrapper.eq(StringUtils.isNotBlank(schoolId), "school_id", schoolId);
        Quarter quarterNow = iQuarterService.getNowQuarter();
        queryWrapper.eq("year_part", quarterNow.getYearPart());
        //queryWrapper.eq("quarter_num",quarterNow.getNum());
        queryWrapper.eq("status", 1);
        List<Grade> gradeList = iGradeService.list(queryWrapper);
        for (Grade grade : gradeList) {
            QueryWrapper<StudentGrade> studentGradeQueryWrapper = new QueryWrapper<>();
            studentGradeQueryWrapper.eq("grade_id", grade.getId());
            Long count = iStudentGradeService.count(studentGradeQueryWrapper);
            grade.setStudentCount(Integer.parseInt(count.toString()));
            Organization organization = iOrganizationService.getById(grade.getSchoolId());
            if (organization != null) {
                Organization organizationNew = new Organization();
                organizationNew.setId(organizationNew.getId());
                organizationNew.setName(organizationNew.getName());
                grade.setSchoolObj(organization);
            }
        }
        return new Result(Code.OK, gradeList, "班级查询完成");
    }

    /**
     * 数据汇总
     */
    @GetMapping("getDataSummaryList")
    public Result getDataSummaryList(@RequestParam Map<String, String> reMap,
                                     @RequestParam(value = "schoolId", defaultValue = "", required = false) String schoolId,
                                     @RequestParam(value = "yearPart", defaultValue = "", required = false) Integer yearPart,
                                     @RequestParam(value = "quarterNum", defaultValue = "", required = false) Integer quarterNum,
                                     @RequestParam(value = "yearClassId", defaultValue = "", required = false) String yearClassId,
                                     @RequestParam(value = "classTypeId", defaultValue = "", required = false) String classTypeId,
                                     @RequestParam(value = "periodsNum", defaultValue = "1", required = false) Integer periodsNum,
                                     @RequestParam(value = "lessonType", defaultValue = "1", required = false) Integer lessonType,
                                     @RequestParam(value = "paymentStatus", defaultValue = "1", required = false) Integer paymentStatus,
                                     @RequestParam(value = "seeRows", defaultValue = "2", required = false) Integer seeRows,
                                     @RequestParam(value = "marketTeacherId", defaultValue = "", required = false) String marketTeacherId,
                                     @RequestParam(value = "teamId", defaultValue = "", required = false) String teamId,
                                     @RequestParam(value = "trackType", defaultValue = "1", required = false) Integer trackType,
                                     @RequestParam(value = "classify", defaultValue = "1", required = false) Integer classify,
                                     @RequestParam(value = "isType", defaultValue = "1", required = false) Integer isType) throws ParseException {
        String subjectsId = reMap.get("subjectsId");
        String startDate = reMap.get("startDate");
        String endDate = reMap.get("endDate");
        String trackId = reMap.get("trackId");

        int type = 1;
//        if(reMap.get("type") != null){
//            type = Integer.parseInt(reMap.get("type"));
//        }
        DataSummaryList dataSummaryList = new DataSummaryList();
        if (schoolId != null && !schoolId.isEmpty()) {
            dataSummaryList.setSchoolId(schoolId);
        }
        if (yearPart != null) {
            dataSummaryList.setYearPart(yearPart);
        }
        if (quarterNum != null) {
            dataSummaryList.setQuarterNum(quarterNum);
        }
        if (yearClassId != null && !yearClassId.isEmpty()) {
            dataSummaryList.setYearClassId(yearClassId);
        }
        if (classTypeId != null && !classTypeId.isEmpty()) {
            dataSummaryList.setClassTypeId(classTypeId);
        }
        dataSummaryList.setPeriodsNum(periodsNum);
        dataSummaryList.setLessonType(lessonType);
        dataSummaryList.setPaymentStatus(paymentStatus);
        dataSummaryList.setSeeRows(seeRows);
        if (subjectsId != null && !subjectsId.isEmpty()) {
            dataSummaryList.setSubjectsId(subjectsId);
        }
        if (startDate != null && !startDate.isEmpty()) {
            dataSummaryList.setStartDate(startDate);
        }
        if (endDate != null && !endDate.isEmpty()) {
            dataSummaryList.setEndDate(endDate);
        }
        if (trackId != null && !trackId.isEmpty()) {
            dataSummaryList.setTrackId(trackId);
        }
        dataSummaryList.setType(type);
        List<RenewClassRecord> renewClassRecordList = null;

        // 获取权限
        AuthAdminContent authAdminContent = iAuthAdminContentService.getPermissionForTeacherId(yearPart, quarterNum, this.adminId, this.baseSchoolIdStr);
        LeadDataRs leadDataRs = authAdminContent.getLeadDataRs();
        if (authAdminContent.getIsPerson() == 1) {
//            if (type != 1 && type != 2) {
//                return new Result(Code.OK, new PageResult<>(new ArrayList<>(), (long) 0, 1L));
//            }
        }

        if (StringUtils.isBlank(yearClassId)) {
            yearClassId = authAdminContent.getYearClassIds();
        } else {
            String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
            leadDataRs.setYearClassIds(leadYearClassId);

            yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
        }

        if (StringUtils.isBlank(subjectsId)) {
            subjectsId = authAdminContent.getSubjectsIds();
        } else {
            String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
            leadDataRs.setSubjectsIds(leadSubjectsId);

            subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
        }

        if (StringUtils.isBlank(schoolId)) {
            schoolId = authAdminContent.getSchoolIds();
        } else {
            String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
            leadDataRs.setSchoolIds(leadSchoolId);

            schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
        }
        // 权限校区id
        String authAdminSchoolId = authAdminContent.getSchoolIdList().stream().map(Object::toString).collect(Collectors.joining(","));

        //isType：1 各年级；2 总数据；3 市场部；4 战队
        if (isType == 1 || isType == 2) {
            dataSummaryList.setIsType(isType);
            renewClassRecordList = iRenewClassService.getDataSummary(dataSummaryList);
        }
        if (isType == 3) {
            renewClassRecordList = iRenewClassService.getPayFeeMarket(schoolId, yearPart, quarterNum, subjectsId, type, startDate, endDate, trackId, lessonType, yearClassId, classTypeId, periodsNum, marketTeacherId, trackType, classify, teamId, authAdminContent, leadDataRs);
        }
        if (isType == 4) {
            renewClassRecordList = iRenewClassService.getPayFeeMarketForTeam(schoolId, yearPart, quarterNum, subjectsId, type, startDate, endDate, trackId, lessonType, yearClassId, classTypeId, periodsNum, marketTeacherId, trackType, classify, teamId, authAdminContent, leadDataRs);
        }
        long total;
        if (renewClassRecordList == null) {
            total = 0;
        } else {
            total = renewClassRecordList.size();
        }
        return new Result(Code.OK, new PageResult<>(renewClassRecordList, total, 1L));
    }

    /**
     * 续报率->赛道
     *
     * @return
     */
    @ApiMethod(value = "home:repeat:continuation-rate", description = "续报率")
    @GetMapping("/continueFeeTeam")
    public Result continueFeeTeam(@RequestParam Map<String, String> reMap,
                                  @RequestParam(value = "schoolId", required = false, defaultValue = "") String schoolId,
                                  @RequestParam(value = "teamId", defaultValue = "", required = false) String teamId,
                                  @RequestParam(value = "trackType", defaultValue = "2", required = false) Integer trackType,
                                  @RequestParam(value = "classify", defaultValue = "4", required = false) Integer classify,
                                  @RequestParam(value = "lessonType", required = false, defaultValue = "1") Integer lessonType
    ) throws ParseException {
        String subjectsId = reMap.get("subjectsId");
        String startDate = reMap.get("startDate");
        String endDate = reMap.get("endDate");
        String trackId = reMap.get("trackId");
        Integer yearPart = Integer.parseInt(reMap.get("yearPart"));
        Integer quarterNum = Integer.parseInt(reMap.get("quarterNum"));
        Integer type = 1;//Integer.parseInt(reMap.get("type"));
        String yearClassId = reMap.get("yearClassId") != null && !reMap.get("yearClassId").isEmpty() ? reMap.get("yearClassId") : null;
        String classTypeId = reMap.get("classTypeId") != null && !reMap.get("classTypeId").isEmpty() ? reMap.get("classTypeId") : null;

        // 获取权限
        AuthAdminContent authAdminContent = iAuthAdminContentService.getPermissionForTeacherId(yearPart, quarterNum, this.adminId, this.baseSchoolIdStr);
        LeadDataRs leadDataRs = authAdminContent.getLeadDataRs();
        if (authAdminContent.getIsPerson() == 1) {
            return new Result(Code.OK, new PageResult<>(new ArrayList<>(), (long) 0, 1L));
        }

        if (StringUtils.isBlank(yearClassId)) {
            yearClassId = authAdminContent.getYearClassIds();
        } else {
            String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
            leadDataRs.setYearClassIds(leadYearClassId);

            yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
        }

        if (StringUtils.isBlank(subjectsId)) {
            subjectsId = authAdminContent.getSubjectsIds();
        } else {
            String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
            leadDataRs.setSubjectsIds(leadSubjectsId);

            subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
        }

        if (StringUtils.isBlank(schoolId)) {
            schoolId = authAdminContent.getSchoolIds();
        } else {
            String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
            leadDataRs.setSchoolIds(leadSchoolId);

            schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
        }
        // 权限校区id
        String authAdminSchoolId = authAdminContent.getSchoolIdList().stream().map(Object::toString).collect(Collectors.joining(","));

        List<ContinueInfo> renewClassRecordList = iRenewClassService.getContinueFeeTeam(yearPart, quarterNum, schoolId, subjectsId, type, startDate, endDate, trackId, lessonType, yearClassId, classTypeId, teamId, trackType, classify, authAdminContent, leadDataRs);

        return new Result(Code.OK, new PageResult<>(renewClassRecordList, (long) renewClassRecordList.size(), 1L));
    }

    /**
     * 续报率详情->赛道
     *
     * @return
     */
    @ApiMethod(value = "home:repeat:continuation-rate", description = "续报率")
    @GetMapping("/getContinueFeeTeamDetail")
    public Result getContinueFeeTeamDetail(
            @RequestParam(value = "yearClassId", required = false) String yearClassId,
            @RequestParam(value = "classTypeId", required = false) String classTypeId,
            @RequestParam(value = "yearPart", required = true) Integer yearPart,
            @RequestParam(value = "quarterNum", required = true) Integer quarterNum,
            @RequestParam(value = "schoolId", required = false, defaultValue = "") String schoolId,
            @RequestParam(value = "subjectsId", required = false, defaultValue = "") String subjectsId,
            @RequestParam(value = "startDate", required = false, defaultValue = "") String startDate,
            @RequestParam(value = "endDate", required = false, defaultValue = "") String endDate,
            @RequestParam(value = "type", required = false, defaultValue = "1") Integer type,
            @RequestParam(value = "teacherId", required = false, defaultValue = "") String teacherId,
            @RequestParam(value = "gradeId", required = false, defaultValue = "") String gradeId,
            @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(value = "teamId", defaultValue = "", required = false) String teamId,
            @RequestParam(value = "trackType", defaultValue = "2", required = false) Integer trackType,
            @RequestParam(value = "classify", defaultValue = "4", required = false) Integer classify,
            @RequestParam(value = "lessonType", required = false, defaultValue = "1") Integer lessonType
    ) throws ParseException {
        IPage<StudentGrade> iPage = new Page<>(pageNum, pageSize);

        // 获取权限
        AuthAdminContent authAdminContent = iAuthAdminContentService.getPermissionForTeacherId(yearPart, quarterNum, this.adminId, this.baseSchoolIdStr);
        LeadDataRs leadDataRs = authAdminContent.getLeadDataRs();
        if (authAdminContent.getIsPerson() == 1) {
            return new Result(Code.OK, new PageResult<>(new ArrayList<>(), (long) 0, 1L));
        }

        if (StringUtils.isNotBlank(teacherId)) {
            if (!teacherId.equals(String.valueOf(leadDataRs.getTeacherId()))) {
                leadDataRs.setTeacherId(0L);
            }
        }

        if (StringUtils.isBlank(yearClassId)) {
            yearClassId = authAdminContent.getYearClassIds();
        } else {
            String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
            leadDataRs.setYearClassIds(leadYearClassId);

            yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
        }

        if (StringUtils.isBlank(subjectsId)) {
            subjectsId = authAdminContent.getSubjectsIds();
        } else {
            String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
            leadDataRs.setSubjectsIds(leadSubjectsId);

            subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
        }

        if (StringUtils.isBlank(schoolId)) {
            schoolId = authAdminContent.getSchoolIds();
        } else {
            String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
            leadDataRs.setSchoolIds(leadSchoolId);

            schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
        }

        iRenewClassService.getContinueFeeDetailTeam(iPage, yearPart, quarterNum, schoolId, subjectsId, type, startDate, endDate, lessonType, teacherId, gradeId, yearClassId, classTypeId, teamId, trackType, classify);

        return new Result(Code.OK, new PageResult<>(iPage.getRecords(), iPage.getTotal(), iPage.getPages()));
    }

    /**
     * 续报率详情->赛道
     *
     * @return
     */
    @GetMapping("/getRenewRecordDetailTeamTeacher")
    public Result getRenewRecordDetailTeamTeacher(
            @RequestParam(value = "yearClassId", required = false) String yearClassId,
            @RequestParam(value = "classTypeId", required = false) String classTypeId,
            @RequestParam(value = "yearPart", required = true) Integer yearPart,
            @RequestParam(value = "quarterNum", required = true) Integer quarterNum,
            @RequestParam(value = "schoolId", required = false, defaultValue = "") String schoolId,
            @RequestParam(value = "subjectsId", required = false, defaultValue = "") String subjectsId,
            @RequestParam(value = "startDate", required = false, defaultValue = "") String startDate,
            @RequestParam(value = "endDate", required = false, defaultValue = "") String endDate,
            @RequestParam(value = "type", required = false, defaultValue = "1") Integer type,
            @RequestParam(value = "teamId", defaultValue = "", required = false) String teamId,
            @RequestParam(value = "trackId", defaultValue = "", required = false) String trackId,
            @RequestParam(value = "trackType", defaultValue = "2", required = false) Integer trackType,
            @RequestParam(value = "classify", defaultValue = "4", required = false) Integer classify,
            @RequestParam(value = "lessonType", required = false, defaultValue = "1") Integer lessonType
    ) throws ParseException {

        // 获取权限
        AuthAdminContent authAdminContent = iAuthAdminContentService.getPermissionForTeacherId(yearPart, quarterNum, this.adminId, this.baseSchoolIdStr);
        LeadDataRs leadDataRs = authAdminContent.getLeadDataRs();
        if (authAdminContent.getIsPerson() == 1) {
            return new Result(Code.OK, new PageResult<>(new ArrayList<>(), (long) 0, 1L));
        }

        if (StringUtils.isBlank(yearClassId)) {
            yearClassId = authAdminContent.getYearClassIds();
        } else {
            String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
            leadDataRs.setYearClassIds(leadYearClassId);

            yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
        }

        if (StringUtils.isBlank(subjectsId)) {
            subjectsId = authAdminContent.getSubjectsIds();
        } else {
            String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
            leadDataRs.setSubjectsIds(leadSubjectsId);

            subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
        }

        if (StringUtils.isBlank(schoolId)) {
            schoolId = authAdminContent.getSchoolIds();
        } else {
            String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
            leadDataRs.setSchoolIds(leadSchoolId);

            schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
        }

        List<ContinueInfo> renewRecordDetailTeamTeacher = iRenewClassService.getRenewRecordDetailTeamTeacher(yearPart, quarterNum, schoolId, subjectsId, type, startDate, endDate, trackId, lessonType, yearClassId, classTypeId, teamId, trackType, classify, authAdminContent, leadDataRs);

        return new Result(Code.OK, renewRecordDetailTeamTeacher);
    }

    /**
     * 数据汇总->续报率
     */
    @GetMapping("getContinueFeeTeamList")
    public Result getContinueFeeTeamList(@RequestParam Map<String, String> reMap,
                                         @RequestParam(value = "schoolId", defaultValue = "", required = false) String schoolId,
                                         @RequestParam(value = "yearPart", defaultValue = "", required = false) Integer yearPart,
                                         @RequestParam(value = "quarterNum", defaultValue = "", required = false) Integer quarterNum,
                                         @RequestParam(value = "yearClassId", defaultValue = "", required = false) String yearClassId,
                                         @RequestParam(value = "classTypeId", defaultValue = "", required = false) String classTypeId,
                                         @RequestParam(value = "periodsNum", defaultValue = "1", required = false) Integer periodsNum,
                                         @RequestParam(value = "lessonType", defaultValue = "1", required = false) Integer lessonType,
                                         @RequestParam(value = "paymentStatus", defaultValue = "1", required = false) Integer paymentStatus,
                                         @RequestParam(value = "seeRows", defaultValue = "2", required = false) Integer seeRows,
                                         @RequestParam(value = "teamId", defaultValue = "", required = false) String teamId,
                                         @RequestParam(value = "trackType", defaultValue = "1", required = false) Integer trackType,
                                         @RequestParam(value = "classify", defaultValue = "1", required = false) Integer classify,
                                         @RequestParam(value = "isType", defaultValue = "1", required = false) Integer isType) throws ParseException {
        String subjectsId = reMap.get("subjectsId");
        String startDate = reMap.get("startDate");
        String endDate = reMap.get("endDate");
        String trackId = reMap.get("trackId");

        int type = 1;
//        if(reMap.get("type") != null){
//            type = Integer.parseInt(reMap.get("type"));
//        }
        DataSummaryList dataSummaryList = new DataSummaryList();
        if (schoolId != null && !schoolId.isEmpty()) {
            dataSummaryList.setSchoolId(schoolId);
        }
        if (yearPart != null) {
            dataSummaryList.setYearPart(yearPart);
        }
        if (quarterNum != null) {
            dataSummaryList.setQuarterNum(quarterNum);
        }
        if (yearClassId != null && !yearClassId.isEmpty()) {
            dataSummaryList.setYearClassId(yearClassId);
        }
        if (classTypeId != null && !classTypeId.isEmpty()) {
            dataSummaryList.setClassTypeId(classTypeId);
        }
        dataSummaryList.setPeriodsNum(periodsNum);
        dataSummaryList.setLessonType(lessonType);
        dataSummaryList.setPaymentStatus(paymentStatus);
        dataSummaryList.setSeeRows(seeRows);
        if (subjectsId != null && !subjectsId.isEmpty()) {
            dataSummaryList.setSubjectsId(subjectsId);
        }
        if (startDate != null && !startDate.isEmpty()) {
            dataSummaryList.setStartDate(startDate);
        }
        if (endDate != null && !endDate.isEmpty()) {
            dataSummaryList.setEndDate(endDate);
        }
        if (trackId != null && !trackId.isEmpty()) {
            dataSummaryList.setTrackId(trackId);
        }
        dataSummaryList.setType(type);
        List<ContinueInfo> renewClassRecordList = null;

        // 获取权限
        AuthAdminContent authAdminContent = iAuthAdminContentService.getPermissionForTeacherId(yearPart, quarterNum, this.adminId, this.baseSchoolIdStr);
        LeadDataRs leadDataRs = authAdminContent.getLeadDataRs();
        if (authAdminContent.getIsPerson() == 1) {
//            return new Result(Code.OK, new PageResult<>(new ArrayList<>(), (long) 0, 1L));
        }

        if (StringUtils.isBlank(yearClassId)) {
            yearClassId = authAdminContent.getYearClassIds();
        } else {
            String leadYearClassId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getYearClassIds(), yearClassId);
            leadDataRs.setYearClassIds(leadYearClassId);

            yearClassId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getYearClassIds(), yearClassId);
        }

        if (StringUtils.isBlank(subjectsId)) {
            subjectsId = authAdminContent.getSubjectsIds();
        } else {
            String leadSubjectsId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSubjectsIds(), subjectsId);
            leadDataRs.setSubjectsIds(leadSubjectsId);

            subjectsId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSubjectsIds(), subjectsId);
        }

        if (StringUtils.isBlank(schoolId)) {
            schoolId = authAdminContent.getSchoolIds();
        } else {
            String leadSchoolId = iAuthAdminContentService.getIntersectionForStr(leadDataRs.getSchoolIds(), schoolId);
            leadDataRs.setSchoolIds(leadSchoolId);

            schoolId = iAuthAdminContentService.getIntersectionForStr(authAdminContent.getSchoolIds(), schoolId);
        }

        // 权限校区id
        String authAdminSchoolId = authAdminContent.getSchoolIdList().stream().map(Object::toString).collect(Collectors.joining(","));

        //isType：1 各年级；2 总数据；3 市场部；4 战队
        if (isType == 1 || isType == 2) {
            dataSummaryList.setIsType(isType);
            renewClassRecordList = iRenewClassService.getDataSummaryRenewRecord(dataSummaryList);
        }
        if (isType == 3) {
            renewClassRecordList = iRenewClassService.getContinueFeeMarket(yearPart, quarterNum, schoolId, subjectsId, startDate, endDate, lessonType, yearClassId, classTypeId, classify, trackType, trackId);
        }
        if (isType == 4) {
            renewClassRecordList = iRenewClassService.getContinueFeeTeam(yearPart, quarterNum, schoolId, subjectsId, type, startDate, endDate, trackId, lessonType, yearClassId, classTypeId, teamId, trackType, classify, authAdminContent, leadDataRs);
        }
        long total;
        if (renewClassRecordList == null) {
            total = 0;
        } else {
            total = renewClassRecordList.size();
        }
        return new Result(Code.OK, new PageResult<>(renewClassRecordList, total, 1L));
    }


    /**
     * 教师带班数据（续报率、缴费率）
     *
     * @return
     */
    @GetMapping("/continueAndPayFee")
    public Result continueAndPayFee(
            @RequestParam(value = "schoolId", required = false) String schoolId,
            @RequestParam(value = "type", required = false, defaultValue = "1") Integer type,
            @RequestParam(value = "yearPart", required = false) Integer yearPart,
            @RequestParam(value = "quarterNum", required = false) Integer quarterNum,
            @RequestParam(value = "subjectsId", required = false) String subjectsId,
            @RequestParam(value = "yearClassId", required = false) String yearClassId,
            @RequestParam(value = "classTypeId", required = false) String classTypeId,
            @RequestParam(value = "name", required = false) String name,
            @RequestParam(value = "trackId", required = false) String trackId,
            @RequestParam(value = "startGradeCount", required = false, defaultValue = "1") String startGradeCount,
            @RequestParam(value = "endGradeCount", required = false, defaultValue = "1") String endGradeCount
    ) throws ParseException {

        if (name == null || name.isEmpty()) {
            name = null;
        }

        // 获取当天日期
        LocalDate localDate = LocalDate.now();
        String startDate = localDate.toString();
        String endDate = localDate.toString();

        Integer periodsNum = 1;
        Integer lessonType = 1;

        List<HashMap<String, Object>> hashMapList = new ArrayList<>();

        List<RenewClassRecord> renewClassRecordList = iRenewClassService.getPayFeeByTeacherIdList(schoolId, yearPart, quarterNum, subjectsId, type, startDate, endDate, trackId, lessonType, yearClassId, classTypeId, periodsNum, name, startGradeCount, endGradeCount);
        List<ContinueInfo> continueInfoList = iRenewClassService.getContinueFeeByTeacherIdList(yearPart, quarterNum, schoolId, subjectsId, type, trackId, lessonType, yearClassId, classTypeId, name, startGradeCount, endGradeCount);

        for (RenewClassRecord renewClassRecord : renewClassRecordList) {

            HashMap<String, Object> hashMap = new HashMap<>();
            hashMap.put("teacherId", renewClassRecord.getTeacherId());
            hashMap.put("teacherName", renewClassRecord.getTeacherName());
            hashMap.put("gradeStudentCount", renewClassRecord.getGradeStudentCount());
            hashMap.put("studentAllCount", renewClassRecord.getStudentAllCount());
            hashMap.put("bigFifteen", renewClassRecord.getBigFifteen());

            for (ContinueInfo continueInfo : continueInfoList) {
                if (continueInfo.getTeacherId().equals(renewClassRecord.getTeacherId()))
                    hashMap.put("schedulingCount", continueInfo.getSchedulingCount());
            }

            hashMapList.add(hashMap);
        }

        return new Result(Code.OK, hashMapList, Code.GET_OK_MSG);
    }

}
